package com.yibo.yunpicture.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yibo.yunpicture.infrastructure.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.yibo.yunpicture.interfaces.dto.picture.*;
import com.yibo.yunpicture.domain.picture.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yibo.yunpicture.domain.user.entity.User;
import com.yibo.yunpicture.interfaces.vo.picture.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author AdminMYB
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-04-25 08:11:00
 */
public interface PictureApplicationService extends IService<Picture> {
    /**
     * 上传图片
     *
     * @param inputSource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadDTO pictureUploadRequest, User loginUser);

    /**
     * 得到图片封装
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 删除图片
     * @param pictureId
     * @param loginUser
     */
    void deletePicture(long pictureId, User loginUser);

    /**
     * 编辑图片
     * @param picture
     * @param loginUser
     */
    void editPicture(Picture picture, User loginUser);

    void validPicture(Picture picture);

    /**
     *查询图片列表
     * @param pictureQueryDTO
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryDTO pictureQueryDTO);

    /**
     * 审核图片
     * @param pictureReviewDTO
     * @param loginUser
     */
    void doPictureReview(PictureReviewDTO pictureReviewDTO, User loginUser);

    /**
     * 填充审核参数
     * @param picture
     * @param loginUser
     */
    void fillReviewParam(Picture picture, User loginUser);

    /**
     * 批量抓取和创建图片
     * @param pictureUploadByBatchDTO
     * @param loginUser
     * @return
     */
    Integer uploadPictureBatch(PictureUploadByBatchDTO pictureUploadByBatchDTO, User loginUser);

    /**
     * 删除图片，这里指的是对象存储中的图片
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);


    /**
     * 如果有空间id需要校验，额外的权限
     *
     * @param loginUser
     * @param oldPicture
     */
    void checkPictureAuth(User loginUser, Picture oldPicture);

    /**
     * 根据颜色搜索图片
     *
     * @param spaceId
     * @param picColor
     * @param loginUser
     * @return
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量编辑图片
     * @param pictureEditByBatchDTO
     * @param loginUser
     */
    void editPictureByBatch(PictureEditByBatchDTO pictureEditByBatchDTO, User loginUser);

    /**
     * 创建扩图任务方法
     * @param createPictureOutPaintingTaskDTO
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskDTO createPictureOutPaintingTaskDTO, User loginUser);
}
